package com.bw.controller.bil;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bw.entity.bil.PiInvoice;
import com.bw.entity.bil.PiInvoiceLog;
import com.bw.resp.ResponseResult;
import com.bw.service.bil.IPiInvoiceLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yzz
 * @since 2020-06-27
 */
@RestController
@RequestMapping("/billog")
public class PiInvoiceLogController {
    @Autowired
    private IPiInvoiceLogService invoiceLogService;
    //定义日志工具
    private final Logger logger = LoggerFactory.getLogger(PiInvoiceLogController.class);
    /**
     * @param id:
     * @Description:根据id回显发票记录
     * @Author: 杨祯祯
     * @Date: 2020/6/27
     * @return: com.bw.resp.ResponseResult
     **/
    @PostMapping("/getById/{id}")
    public ResponseResult getBilById(@PathVariable("id") Long id) {
        logger.info("发票操作回显查询开始");
        ResponseResult re = new ResponseResult(false, 400, "查询失败");
        try {
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("invoiceId",id);
            List<PiInvoiceLog> list = invoiceLogService.list(queryWrapper);
            re.setSuccess(true);
            re.setMessage("查询成功");
            re.setCode(200);
            re.setResult(list);//存储
            logger.info("发票操作回显查询结束");
            return re;
        } catch (Exception e) {
            logger.error("发票操作回显查询失败,{}", e.toString());
            return re;
        }
    }
}
